package com.shuzijun.leetcode.editor.cn;
public class ValidPerfectSquare{
    public static void main(String[] args) {
         Solution solution = new ValidPerfectSquare().new Solution();
        
    }
    //leetcode submit region begin(Prohibit modification and deletion)
class Solution {
    public boolean isPerfectSquare(int num) {
        int low = 1;
        int high = num;
        while (low <= high){
            int mid = low + (high - low) / 2;
            long mid2 = (long) mid * mid;
            if (mid2 == num){
                return true;
            } else if (mid2 > num) {
                high = mid-1;
            }else {
                low = mid+1;
            }
        }
        return false;
    }
}
//leetcode submit region end(Prohibit modification and deletion)

}